class Singleton {
    private static Singleton instance;
    public int value;

    private Singleton() {
        this.value = 0;
    }

    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();

        s1.value = 42;
        System.out.println("s1.value: " + s1.value); // 输出 42
        System.out.println("s2.value: " + s2.value); // 也输出 42，因为 s1 和 s2 是同一个实例
    }
}
